--裁接
local caijie = fk.CreateSkill {
    name = "mcdh_caijie",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

caijie:addEffect(fk.TargetSpecifying,{
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(self) and player:getMark("mcdh_charge") >= 3 and data.firstTarget and data.card.trueName == "slash" and data.card.name ~= "slash"
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local all_choice = {"caijie1:"..target.id,"caijie2:"..target.id,"Cancel"}
        local choices = all_choice
        if target:isKongcheng() then
            table.removeOne(choices,"caijie1:"..target.id)
        end
        local choice = room:askForChoice(player, choices, self.name)
        if choice ~= "Cancel" then
            self.cost_data = choice
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        lib.LoseCharge(player,player,3,self.name)
        if self.cost_data == "caijie1:"..target.id then
            local id = room:askForCardChosen(player, target, "h", self.name)
            room:throwCard({id}, self.name, target, player)
            local  to = lib.askForAddTarget(target, data, true,self.name)
            AimGroup:addTargets(player.room, data, to)
        else
            target:drawCards(1,self.name)
            local targets = AimGroup:getAllTargets(data.tos)
            local tos = room:askForChoosePlayers(target, targets, 1, 1, "#caijie-choose", self.name, false)[1]
            table.insertIfNeed(data.nullifiedTargets, tos)
        end
    end
})

Fk:loadTranslationTable {
    ["mcdh_caijie"] = "裁接",
    [":mcdh_caijie"] = "『裁剪焊接』<br>蓄力技(3)，当一名角色使用属性【杀】指定目标时，你可以选择一项：1.弃置其一张手牌，令其为此牌增加一个目标；2.其摸一张牌并令此牌对其中一个目标无效。",
    ["caijie1"] = "1.弃置 %src一张手牌，令其为此牌增加一个目标",
    ["caijie2"] = "2.%src 摸一张牌并令此牌对其中一个目标无效。",
    ["#caijie-addTarget"] = "裁接: 为此牌增加一个目标",
    ["#caijie-choose"] = "裁接: 令此牌对一个目标无效"
}

return caijie